<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<%@page import="com.framework.utils.ConfigUtil"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <style>
        .dtupload>img{
            width: 54px;
            padding-left: 39px;
            padding-top: 16px;
        }
        .dtupload>a{
            color: #268eff;
            font-size: 12px;
            position: relative;
            left: 26px;
            top: 10px;
        }.dtupload>a:hover,
         .shoplogo>a:hover{
             color:#F93;
         }.upload_pic {
              height: 70px;
              width:70px;
              position: relative;
              cursor: pointer;
              color: #ccbe9e;
              background: #fff;
              overflow: hidden;
              display: inline-block;
              *display: inline;
              *zoom: 1;
          }
        .upload_pic input {
            position: absolute;
            height:100%;
            width:100%;
            right: 0;
            top: 0;
            opacity: 0;
            filter: alpha(opacity=0);
            cursor: pointer
        }
        .upload_pic:hover {
            color: #ccbe9e;
            background: #fff;
            text-decoration: none
        }
    </style>
</head>

<div class="wrapper wrapper-content">
    <div class="panel-body">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form onsubmit="return  false" class="form-horizontal" id="signupForm">
                        <input id="mebactivity_id" name="pmebactivity.id" type="hidden">
                        <input type="hidden"  name="pmebactivity.startTime" value="${startTime}"/>
                        <input type="hidden"  name="pmebactivity.endTime" value="${endTime}"/>
                        <input type="hidden" name="pmebactivity.period" value="${period}"/>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动名称：</label>
                            <div class="col-sm-8">
                                <input id="mebactivity_name"  name="pmebactivity.name" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动图片：</label>
                            <div class="col-sm-4">
                                <!--上传logo-->
                                <div class="dtupload">
                                    <a href="javascript:" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="fileToUpload1" onChange="uploadFile('fileToUpload1','imgUpdate','shopPicId');">
                                        <img  id="imgUpdate" src="${pageContext.request.contextPath}/resources/image/logopic1.png" width="100%"/>
                                        <input type="hidden" id="shopPicId" name="pmebactivity.picId">
                                    </a>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">设置中奖人数：</label>
                            <div class="col-sm-8">
                                <input id="mebactivity_count" onblur="checkNum(this);" name="pmebactivity.count" class="form-control" type="number">
                            </div>
                        </div>

                        <div class="form-group" id="showLoginName">
                            <label class="col-sm-3 control-label">开奖日期：</label>
                            <div class="col-sm-8">
                                <input id="mebactivity_lotteryTime" readonly="readonly" value="${lotteryTime}"  name="pmebactivity.lotteryTime" class="form-control" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动描述：</label>
                            <div class="col-sm-8">
                                <input id="mebactivity_note"  name="pmebactivity.note" class="form-control" type="text">
                            </div>
                        </div>


                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" onclick="doSubmit();">提交</button>
                                <button id="btn_close"  class="btn btn-primary" type="button">关闭</button>
                              <%--  <button id="transmit"  class="btn btn-primary" type="button">给父页面传值</button>--%>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/utf8-jsp/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/utf8-jsp/ueditor.all.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/validate/messages_zh.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/demo/form-validate-demo.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer2.4/layer.js"></script>

<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.5"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/jsKnob/jquery.knob.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/jasny/jasny-bootstrap.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/nouslider/jquery.nouislider.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/switchery/switchery.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/iCheck/icheck.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/clockpicker/clockpicker.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/cropper/cropper.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/demo/form-advanced-demo.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script>

<script src="${pageContext.request.contextPath}/resources/plugins/ueditor1_4_2-utf8-jsp/ueditor.config.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ueditor1_4_2-utf8-jsp/ueditor.all.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ueditor1_4_2-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">

</script>

<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>

<script>

        if('${id}'!=null&&'${id}'!=undefined&&'${id}'!='')
        {
        loadInfo('${id}');
        }

    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    //parent.layer.iframeAuto(index);
    //让层自适应iframe
    $('#add').on('click', function(){
        $('body').append('插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。');

    });
    //给父页面传值
    $('#transmit').on('click', function(){

    });

    //关闭iframe
    $('#btn_close').click(function(){
        parent.layer.close(index);
    });


function doSubmit()
{
    var name=$("#mebactivity_name").val();
    var count=$("#mebactivity_count").val();
    var pic=$("#shopPicId").val();


    var isOk=true;
    if(name==null||name==undefined||name==''){alert("请输入名称");isOk= false;}
    if(count==null||count==undefined||count==''){alert("请输入参与人数");isOk= false;}
    if(pic==null||pic==undefined||pic==''){alert("请上传图片");isOk= false;}
if(isOk){
    $.ajax( {
        url:'${pageContext.request.contextPath}/mebactivity/doSave.ac',// 跳转到 action
        data:$("#signupForm").serialize(),
        type:'post',
        cache:false,
        dataType:'json',
        success:function(data) {
           if(data=="success")
           {
               alert("操作成功！");
               parent.layer.close(index);
               alert(1);
           }else
           {
               alert(data);
           }
        },
        error : function() {
            alert("操作失败！");
        }
    });
}
}
function  checkNum(obj) {
    if(obj.value<0)
    {alert("请正确输入参与人数!");
    obj.value=0;}
}
    var picPath='<%=ConfigUtil.get("OSSURL")%>';

function uploadFile(obj,id,picId){//上传图片
    var labid = "";
    //var detailId = $("#detailId").val();
    //$("#"+id).css("background","url(${pageContext.request.contextPath}/resources/assets/images/waiting.gif) no-repeat 0 0/100% 100%");
    $.ajaxFileUpload({
        url: '${pageContext.request.contextPath}/common/doUploadFile.ac',
        secureuri: false,
        type:'post',
        fileElementId: obj,
        dataType: 'text',
        success: function(data, status) {
            var img=JSON.parse(data);
            $("#"+id).attr("src",picPath+img.path);
            $("#"+picId).val(img.picId);

        },
        error: function(data, status, e) {
            alert(e);
        }
    });
}

function  loadInfo(id) {
    $.ajax( {
        url:'${pageContext.request.contextPath}/mebactivity/loadInfo.ac',// 跳转到 action
        data:{id:id},
        type:'post',
        cache:false,
        dataType:'json',
        success:function(data) {
            $("#mebactivity_name").val(data.name);
            $("#mebactivity_count").val(data.count);
            $("#mebactivity_note").val(data.note);
            $("#mebactivity_lotteryTime").val(data.lotteryTime);
            $("#mebactivity_id").val(data.id);
            $("#shopPicId").val(data.picId);
            $("#imgUpdate").attr("src",picPath+data.imgUrl);

        },
        error : function() {
            alert("操作失败！");
        }
    });
}
</script>

</body>

</html>

